package com.ftg.learn.util;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * 配置文件 在线文档
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/4/3 下午3:40
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

    @Bean(value = "dockerBean")
    public Docket dockerBean() {
        //指定使用Swagger2规范
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        //描述字段支持Markdown语法
                        .description("这是我们的在线文档")
                        .termsOfServiceUrl("https://doc.xiaominfo.com/")
                        .contact("kangjx")
                        .version("1.0")
                        .build())
                //分组名称
                .groupName("测试模块")
                .select()
                //这里指定Controller扫描包路径
                .apis(RequestHandlerSelectors.basePackage("com.ftg.learn.system.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
